package com.momo.oauth.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * Created by Kagome on 2019/5/10.
 * 登录身份证认证
 */

@Slf4j
@Service(value = "userService")
public class UserServiceImpl implements UserDetailsService {

//    @Autowired
//    private SysAccountRepository repository;

    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//        SysAccount user = repository.findByUserAccount(username);
//        if(user == null){
//            log.info("登录用户【"+username + "】不存在.");
//            throw new UsernameNotFoundException("登录用户【"+username + "】不存在.");
//        }
        log.error("登录");
        return new org.springframework.security.core.userdetails.User("account", "pwd", getAuthority());
    }

    private List getAuthority() {
        return Arrays.asList(new SimpleGrantedAuthority("ROLE_ADMIN"));
    }


}
